package com.bjpowernode.crm.web.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("cache")
public class CacheController {
    // /cache/options.json?type=xxx
    @GetMapping("options.json")
    public List options(String type, HttpServletRequest request) {
        Map<String, List> options = (Map) request.getServletContext().getAttribute("options");
        return options.get(type);
    }
    // /cache/xxx
    @GetMapping("{type}")
    public List options2(@PathVariable String type, HttpServletRequest request) {
        Map<String, List> options = (Map) request.getServletContext().getAttribute("options");
        return options.get(type);
    }
}
